package com.ipzoe.web.task;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.ipzoe.mem.domain.Member;
import com.ipzoe.oms.domain.Order;
import com.ipzoe.oms.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class OrderTask {
    @Autowired
    private IOrderService iOrderService;

    /**
     * 订单支付超时
     */
    public void orderPayExpire(){
        //处理待付款订单，半个小时未付款则订单无效
        LambdaUpdateWrapper<Order> luw = new LambdaUpdateWrapper<>();
        luw.set(Order::getStatus, 5);
        luw.eq(Order::getStatus, 0);
        luw.le(Order::getCreateTime, DateUtil.offsetMinute(new Date(), -30));
        iOrderService.update(luw);
    }
}
